﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Surface.Presentation.Controls;
using Microsoft.Surface;
using Microsoft.Surface.Presentation;
using System.Windows;
using System.Windows.Controls;
using MapSurface.WidgetSurface;
using MapSurface.UIModelElement;
using System.Xml;
using MapSurface.AssemblyReflexion;


namespace MapSurface.Engine
{
    public class UIModelChoiceLoader
    {
        #region Loader Properties
        private string dllFile;
        private String _docxmi = null;
        public String DocXMI
        {
            get { return _docxmi; }
            set { _docxmi = value; }
        }
        private XamlObjects loader;
        public XamlObjects XamlObject
        {
            get { return loader; }
            set { loader = value; }
        }
        private string dllDir = null;
        public AssemblyReflexion.AssemblyReflexion Assembly
        {
            get {
                if (loader == null)
                //    loader = new XamlObjects(_docxmi, "",dllDir);
                return loader.Assembly; 
            }
        }
        public XamlObjects Loader
        {
            get { return loader; }
            set { 
                loader = value; 
            }
        }
        private ChoiceTableManager _manager = null;
        public ChoiceTableManager Manager
        {
            get { return _manager; }
            set { _manager = value; }
        }
        #endregion
        
        #region Contructors
        public UIModelChoiceLoader(string dllFile)
        {
            this.dllFile = dllFile;
        }

        public  UIModelChoiceLoader(String  xmifile,string dllDir,string choiceFile,string apiFile)
        {
            _docxmi = xmifile;
            //loader = new XamlObjects(xmifile,"",dllDir);
           // loader.ApiFile = apiFile;
            //edit = new EditModelLoad();
            Manager = new ChoiceTableManager(choiceFile, Assembly);
            this.dllDir = dllDir;
        }

        public void setLoader(string xmiFile,string dllDir,string choiceFile)
        {
            _docxmi = xmiFile;
            loader = new XamlObjects(xmiFile, "",dllDir);
            Manager = new ChoiceTableManager(choiceFile, Assembly);
            this.dllDir = dllDir;
        }
        #endregion

        #region Loader

        public void loadUIModel(string xmiFile, string choiceFile)
        {

        }

        public List<Object> process(Object context)
        {
           // return loader.load(context);
            return null;
        }

        public List<Object> getChoiceElement(Object selectObject)
        {
            //Type t = selectObject.GetType();
            //MapSurface.UIModelElement.UIElement e = loader.UIModelManager.findInstance(selectObject);
            //Manager.Model = Loader.UiModel;
            //if(e!=null)
            //    return Manager.getEquivalentInstance( e);
             return null;
        }
         #endregion
    }
}
